﻿using UnityEngine;
using System.Collections;
using CommandModel;
// Command pattern -- Structural example   
using System; 
public	enum CommandExample{
	Test,
	Compute,
}
/**//// <summary> 
///  Client test 
/// </summary> 
public class CommandClient:MonoBehaviour
{ 
	
	public CommandExample example;
	public void Start( ) 
	{ 

		switch(example){
		case CommandExample.Test:
			TestCommand ();
			break;
		case CommandExample.Compute:
			ComputeCommand ();
			break;
		}
		
	} 

	public void TestCommand(){
		// Create receiver, command, and invoker 
		Receiver r = new Receiver(); 
		Command c = new ConcreteCommand( r ); 
		Invoker i = new Invoker(); 

		// Set and execute command 
		i.SetCommand(c); 
		i.ExecuteCommand(); 
	}

	public void ComputeCommand(){
		User user = new User ();
		user.Compute ('+', 100);
		user.Compute ('-', 50);
		user.Compute ('*', 10);
		user.Compute ('/', 2);
		//0 --> 100 --> 50 --> 500 --> 250
		user.UnDo(3);
		user.Redo (1);

		user.Redo ();
		user.UnDo ();
	}
}